function validateCommentForm(form){
    var str = cleanDoubleSpaces(form["text"].value);
    if(!str || str == ' '){
        showError("Empty comment text");
        return false;
    }
    return true;
}
        
function submitAndRefreshComment(form){
    $.post($(form).attr("action"), $(form).serialize(), function(){
        form["text"].value = "";
        showInfo('Success!');
        loadComments($("#url-list").val(), 1); 
    });
}

function clicked_pagelink(href, urlList){
    var query = arr_query(href);
    loadComments(urlList, query['page']);
    //end click
    return false;
}
function loadComments(urlList, page){
    $.get(urlList + "&page=" + page, function(data){
        $("#comment-list").html(data);
        set_pageslink_onclick();
    });
}
    
function set_pageslink_onclick(){
    $("#pages > a").click(function(){
        return clicked_pagelink($(this).attr("href"), $("#url-list").val());
    });
}